<template>
    <div class="page-content">
        <div class="container">
            <div class="row">

                <div class="col-xl-3 col-lg-4 col-md-12 theiaStickySidebar">
                    <div class="settings-widget dash-profile">
                        <div class="settings-menu p-0">
                            <div class="profile-bg">
                                <h5>Beginner</h5>
                                <img src="assets/img/instructor-profile-bg.jpg" alt="">
                                <div class="profile-img">
                                    <a href="instructor-profile.html"><img src="assets/img/user/user15.jpg" alt=""></a>
                                </div>
                            </div>
                            <div class="profile-group">
                                <div class="profile-name text-center">
                                    <h4><a href="instructor-profile.html">{{ userInfo?.user.name }}</a></h4>
                                    <p>校长</p>
                                </div>
                                <div class="go-dashboard text-center">
                                    <a href="add-course.html" class="btn btn-primary">添加教师</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="settings-widget account-settings">
                        <div class="settings-menu">
                            <h3>仪表盘</h3>
                            <ul>
                                <li class="nav-item ">
                                    <NuxtLink to="/master" exact-active-class="active" class="nav-link">
                                        <i class="feather-home"></i> 我的主页
                                    </NuxtLink>
                                </li>
                                <li class="nav-item">
                                    <NuxtLink to="/master/course" exact-active-class="active" class="nav-link">
                                        <i class="feather-book"></i> 我的课程
                                    </NuxtLink>
                                </li>
                                <li class="nav-item">
                                    <NuxtLink to="/master/teacher" exact-active-class="active" class="nav-link">
                                        <i class="feather-book"></i> 我的教师
                                    </NuxtLink>

                                </li>
                                <li class="nav-item">
                                    <NuxtLink to="/master/class" exact-active-class="active" class="nav-link">
                                        <i class="feather-star"></i> 我的班级
                                    </NuxtLink>
                                </li>
                                <li class="nav-item">
                                    <a href="instructor-earnings.html" class="nav-link">
                                        <i class="feather-pie-chart"></i> 我的学生
                                    </a>
                                </li>

                                <li class="nav-item">
                                    <NuxtLink to="/master/student" exact-active-class="active" class="nav-link">
                                        <i class="feather-users"></i> 我的试卷
                                    </NuxtLink>
                                </li>
                                <li class="nav-item">
                                    <a href="instructor-tickets.html" class="nav-link">
                                        <i class="feather-server"></i> 我的考试
                                    </a>
                                </li>

                            </ul>
                            <div class="instructor-title">
                                <h3>账号信息</h3>
                            </div>
                            <ul>

                                <li class="nav-item">
                                    <NuxtLink to="/master/settings" exact-active-class="active" class="nav-link">
                                        <i class="feather-settings"></i> 编辑信息
                                    </NuxtLink>
                                </li>
                                <li class="nav-item">
                                    <NuxtLink to="/master/security" exact-active-class="active" class="nav-link">
                                        <i class="feather-user"></i> 账号安全
                                    </NuxtLink>
                                </li>
                                <li class="nav-item">
                                    <a href="instructor-social-profiles.html" class="nav-link">
                                        <i class="feather-power"></i> 退出登录
                                    </a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>


                <div class="col-xl-9 col-lg-8 col-md-12">
                    <NuxtPage />
                </div>

            </div>
        </div>
    </div>
</template>
<script setup>
// definePageMeta({
//     middleware: [
//         function (to, from) {
//             // 自定义内联中间件
//             if (process.server) return
//             const userInfo = useUseInfo()
//             if (!userInfo.value.tokenString) {
//                 return navigateTo('/login')
//             }
//         },
//     ],
// });

const userInfo = useUseInfo()
// onMounted(async () => {
//     await nextTick();
//     const data = await masterApi.info()
//     userInfo.value.user = Object.assign({}, userInfo.value.user, data)
//     console.log('用户的信息是：')
//     console.dir(userInfo.value.user)
// })
onMounted(() => {
    if (process.server) return
    const userInfo = useUseInfo()
    if (!userInfo.value.tokenString) {
        return navigateTo('/login')
    }
}) 
</script>
<style scoped></style>